<?php

class Module_Impl_Blog_Opration extends Module_Impl_Abstarct_Opration  {
	protected $_tablename = Config_Table::TABLE_BLOG;	
	protected $_objectname = "Object_Blog";
	
	const FAIL_TO_UPDATE_BECAUSE_NO_EXIST = 'mail.update.fail.no.exist';
	const FAIL_TO_DELETE_BECAUSE_NO_EXIST = 'mail.delete.fail.no.exist';
	
	protected $_magic_field_count = array(
			'user_id'       =>array(
								'table' => Config_Table::TABLE_USER,
								'field' => 'blogs_count',
								'step' => 1
		                       ),
	        'category_id'   =>array(
								'table' => Config_Table::TABLE_BLOG_CATEGORY,
								'field' => 'blogs_count',
								'step' => 1
		                      )	
		);
			
	protected function __construct(){
		parent::__construct();	
		$this->_interface_select = Module_Impl_Blog_Select::getInstance();
	}
	/**
	 * Singleton instance
	 * @var Module_Impl_Blog_Opration
	 */
	protected static $_instance = null;
	/**
	 * Singleton instance 
	 * @return Module_Impl_Blog_Opration
	 */
	public static function getInstance() {
		if (null === self::$_instance) {
			self::$_instance = new self ( );
		}
		return self::$_instance;
	}		
	
	public function insert($info){
		$id = parent::insert($info);
		//tag 
		/*if(isset($info['tags_list'])){
			$tags = $info['tags_list'];
			$tt = Module_Blog_Tag_Relation::getInstance();
			foreach ($tags as $tag){
				$relation_info['tag_id'] = $tag;
				$relation_info['blog_id'] = $id;
				$tt->insert($relation_info);		
			}
		}*/
		return $id;
	}	
}